﻿#define  _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
int main()
{
    int n = 0;
    while (~scanf("%d", &n))
    {
        for (int i = 0; i < n; i++)
        {
            int upper = 0, lower = 0, digit = 0, other = 0;
            char a[101] = { 0 };
            scanf("%s", a);
            if (strlen(a) < 8)
            {
                printf("NO\n");
                continue;
            }
            if (a[0] >= '0' && a[0] <= '9')
            {
                printf("NO\n");
                continue;
            }
            char* ptr = a;
            while (*ptr != '\0')
            {
                if (*ptr >= 'a' && *ptr <= 'z')
                    lower++;
                else if
                    (*ptr >= 'A' && *ptr <= 'Z') upper++;
                else if
                    (*ptr >= '0' && *ptr <= '9') digit++;
                else
                    other++;
                ptr++;
            }
            if (other > 0)
            {
                printf("NO\n");
                continue;
            }
            if ((upper > 0) + (lower > 0) + (digit > 0) < 2)
            {
                printf("NO\n");
                continue;
            }
            printf("YES\n");

        }
    }

    return 0;
}